EXECUTE_PROCESS(
	COMMAND ${CMAKE_C_COMPILER} -dumpversion
	OUTPUT_VARIABLE GCC_VERSION
)
if (GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7)
EXECUTE_PROCESS(
	COMMAND svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
	WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
EXECUTE_PROCESS(
	COMMAND svn co http://llvm.org/svn/llvm-project/cfe/trunk clang
	WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/llvm/tools
)
EXECUTE_PROCESS(
	COMMAND svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
	WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/llvm/projects
)
EXECUTE_PROCESS(
	COMMAND mkdir build
	WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
EXECUTE_PROCESS(
	COMMAND cmake ${CMAKE_CURRENT_BINARY_DIR}/llvm
	WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/build
)
ADD_CUSTOM_TARGET(llvm ALL make
	WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/build
)
ADD_CUSTOM_TARGET(clean make clean
	WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/build
)
INSTALL(
	CODE "
	EXECUTE_PROCESS(
		COMMAND make install
		WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/build
	)
	"
)
else()
MESSAGE("skip: LLVM is required GCC version 4.7 or later.")
endif()
